/*
 * Copyright (C) 2012-2014 Freescale Semiconductor, Inc.
 *
 * Configuration settings for the Freescale i.MX6Q sbc board.
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */

#ifndef __MX6QSBC_CONFIG_H
#define __MX6QSBC_CONFIG_H

#define CONFIG_MACH_TYPE		3529
#define CONFIG_CONSOLE_DEV		"ttymxc3"
#define CONFIG_MMCROOT			"/dev/mmcblk2p2"  /* SDHC3 */


#include "mx6sabre_common.h"
#include <asm/imx-common/gpio.h>


#define CONFIG_NR_DRAM_BANKS            1
#define PHYS_SDRAM                      MMDC0_ARB_BASE_ADDR

#define CONFIG_SYS_SDRAM_BASE           PHYS_SDRAM
#define CONFIG_SYS_INIT_RAM_ADDR        IRAM_BASE_ADDR
#define CONFIG_SYS_INIT_RAM_SIZE        IRAM_SIZE

#define CONFIG_SYS_INIT_SP_OFFSET       (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
#define CONFIG_SYS_INIT_SP_ADDR         (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)










//-------------------------------------------------------------------------------------------------
// 	Configure	
//-------------------------------------------------------------------------------------------------
#define CONFIG_BOOTDELAY	3
#define CONFIG_MXC_UART_BASE	UART4_BASE

#define CONFIG_NAND_USE_BOOL	0
#define CONFIG_SDIF_USE_BOOL	1
#define CONFIG_EMMC_USE_BOOL	1
#define CONFIG_ENET_USE_BOOL	1
		#define CONFIG_ENET_ETHADDR		12:34:56:78:9A:BC
		#define CONFIG_ENET_IPADDR		192.168.1.16
		#define CONFIG_ENET_SERVERIP		192.168.1.3	
		#define CONFIG_EMMC_GATEWAYIP		192.168.1.1
		#define CONFIG_ENET_NETMASK		255.255.255.0
		#define CONFIG_ARP_TIMEOUT     		200UL
#define CONFIG_USBHOST_USE_BOOL	1
#define CONFIG_USBUDC_USE_POOL	1
















//-------------------------------------------------------------------------------------------------
//	Fixed
//-------------------------------------------------------------------------------------------------
#if	CONFIG_NAND_USE_BOOL
  	#endif

#if CONFIG_SDIF_USE_BOOL
	#define CONFIG_FSL_ESDHC
	#define CONFIG_FSL_USDHC
	#define CONFIG_SYS_FSL_ESDHC_ADDR      0
	#define CONFIG_MMC
	#define CONFIG_CMD_MMC
	#define CONFIG_GENERIC_MMC
	#define CONFIG_BOUNCE_BUFFER
	#define CONFIG_CMD_EXT2
	#define CONFIG_CMD_FAT
	#define CONFIG_DOS_PARTITION
	#endif

#if CONFIG_EMMC_USE_BOOL
	#define CONFIG_SUPPORT_EMMC_BOOT
	#endif

#if CONFIG_ENET_USE_BOOL
	#define CONFIG_CMD_NET
	#define CONFIG_CMD_PING
	#define CONFIG_CMD_DHCP
	#define CONFIG_CMD_MII
	#define CONFIG_CMD_NET
	#define CONFIG_FEC_MXC
	#define CONFIG_MII
	#define CONFIG_PHYLIB
	#define CONFIG_PHY_ATHEROS
	#define IMX_FEC_BASE          			ENET_BASE_ADDR
	#define CONFIG_FEC_XCV_TYPE       		RGMII
	#define CONFIG_ETHPRIME           		"FEC"
	#define CONFIG_FEC_MXC_PHYADDR    		1
	#define CONFIG_ETHADDR 				CONFIG_ENET_ETHADDR
	#define CONFIG_NETMASK 				CONFIG_ENET_NETMASK
	#define CONFIG_IPADDR 				CONFIG_ENET_IPADDR
	#define CONFIG_SERVERIP 			CONFIG_ENET_SERVERIP
	#define CONFIG_GATEWAYIP			CONFIG_EMMC_GATEWAYIP
	#else
	#undef 	CONFIG_CMD_NET
	#undef 	CONFIG_CMD_CDP
	#undef 	CONFIG_CMD_DNS
	#undef 	CONFIG_CMD_LINK_LOCAL
	#undef 	CONFIG_CMD_NFS
	#undef 	CONFIG_CMD_PING
	#undef 	CONFIG_CMD_RARP
	#undef 	CONFIG_CMD_SNTP
	#undef 	CONFIG_USB_HOST_ETHER
	#undef 	CONFIG_PHYLIB
	#undef 	CONFIG_PHY_ATHEROS
	#endif

#if CONFIG_USBHOST_USE_BOOL
	#define CONFIG_USB_EHCI
	#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
	#define CONFIG_USB_EHCI_MX6
	#define CONFIG_CMD_USB
	#define CONFIG_USB_STORAGE
	#define CONFIG_MXC_USB_PORTSC  (PORT_PTS_UTMI | PORT_PTS_PTW)
	#define CONFIG_MXC_USB_FLAGS   0
	#define CONFIG_USB_MAX_CONTROLLER_COUNT 	2	 /* Enabled USB controller number */
	#endif

#if CONFIG_USBUDC_USE_POOL
	#define CONFIG_IMX_UDC	1
	#endif

#undef CONFIG_SYS_USE_EIMNOR


//-----------------------------------------------------------------------------
//	Physical memory map
//-----------------------------------------------------------------------------
#undef CONFIG_MFG_NAND_PARTITION
/*Since the pin conflicts on EIM D18, disable the USB host if the NOR flash is enabled */
#if !defined(CONFIG_SYS_USE_SPINOR) && !defined(CONFIG_SYS_USE_EIMNOR)
/* USB Configs */
//#define CONFIG_USB_HOST_ETHER
//#define CONFIG_USB_ETHER_ASIX
//#define CONFIG_MXC_USB_PORTSC  (PORT_PTS_UTMI | PORT_PTS_PTW)
//#define CONFIG_MXC_USB_FLAGS   0
//#define CONFIG_USB_MAX_CONTROLLER_COUNT 2 /* Enabled USB controller number */

/* MAX7310 configs  */
#define CONFIG_MAX7310_IOEXP
#define CONFIG_IOEXP_DEVICES_NUM 3
#define CONFIG_IOEXP_DEV_PINS_NUM 8
#endif


#ifdef CONFIG_SYS_USE_SPINOR
#define CONFIG_SF_DEFAULT_CS   (1|(IMX_GPIO_NR(3, 19)<<8))
#endif


/*---------------------------------------------------------------------------------------------------------------------
	filesystem
-----------------------------------------------------------------------------------------------------------------------*/
#define CONFIG_FAT_WRITE


/*---------------------------------------------------------------------------------------------------------------------
	Uboot
-----------------------------------------------------------------------------------------------------------------------*/
#define CONFIG_SYS_PROMPT		"imx6sbc# "

#undef  CONFIG_EXTRA_ENV_SETTINGS
#define CONFIG_EXTRA_ENV_SETTINGS	\
	"console=" \
                "ttymxc3,115200n8\0" \
        "bootfile=" \
                "uImage\0" \
        "loadaddr=" \
                "0x12000000\0" \
        "dtbaddr=" \
                "0x18000000\0" \
        "dtbfile=" \
                "imx6q-sbc.dtb\0" \
        "serverip=" \
                "192.168.1.3\0" \
        "ipaddr=" \
                "192.168.1.179\0" \
        "nfsdir=" \
                "/opt/industech/imx6q-sbc/out/filesystem,v3,tcp\0" \
        "netargs=" \
                "setenv bootargs console=${console} ${optargs} ip=dhcp root=/dev/nfs rw nfsroot=${serverip}:${nfsdir}\0" \
        "netboot=" \
                "run netargs; tftp ${loadaddr} ${bootfile}; tftp ${dtbaddr} ${dtbfile}; bootm ${loadaddr} - ${dtbaddr}\0"\
        "emmcroot=" \
                "root=/dev/mmcblk2p2 rootfstype=ext4 rw rootwait\0" \
        "emmcargs=" \
                "setenv bootargs console=${console} ${optargs} ${emmcroot}\0" \
        "emmcboot=" \
                "run emmcargs; mmc rescan; mmc dev 1; " \
                "fatload mmc 1 ${loadaddr} ${bootfile};" \
                "fatload mmc 1 ${dtbaddr} ${dtbfile};" \
                "bootm ${loadaddr} - ${dtbaddr}\0" \
        "mmcroot=" \
                "root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait\0" \
        "mmcargs=" \
                "setenv bootargs console=${console} ${optargs} ${mmcroot}\0" \
        "mmcboot=" \
                "run mmcargs; mmc rescan;" \
                "fatload mmc 0 ${loadaddr} ${bootfile};" \
                "fatload mmc 0 ${dtbaddr} ${dtbfile};" \
                "bootm ${loadaddr} - ${dtbaddr}\0"

#undef  CONFIG_BOOTCOMMAND	
#define CONFIG_BOOTCOMMAND  \
	"run emmcboot "

#define CONFIG_ENV_IS_IN_MMC
#define CONFIG_SYS_MMC_ENV_DEV          1      
#define CONFIG_SYS_MMC_ENV_PART         0  
#undef  CONFIG_ENV_OFFSET
#define CONFIG_ENV_OFFSET		10240


#endif                         /* __MX6QSABREAUTO_CONFIG_H */
